
import { defineStore } from "pinia"
import { ref } from "vue"


// 组合式 
export const useUserStore = defineStore('user', () => {
    const profile = ref(null)

    function loginByTestPhone(userInfo) {
        profile.value = userInfo
    }
    return { profile, loginByTestPhone }
},
    { // uniapp 重写存储数据的api
        persist: {
            //修改key的命名 不修改默认以上边的user命名key
            // key:'userInfo',
            // storage:localStorage,
            storage: {
                getItem(key) {
                    return uni.getStorageSync(key)
                },
                setItem(key, val) {
                    uni.setStorageSync(key, val)
                }
            }
        }
    })